package com.ht.medicaltreatment.activity

import androidx.activity.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.gym.baselib.base.BaseActivity
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.adapter.InventoryDetailAdapter
import com.ht.medicaltreatment.viewmodel.InventoryOrderDetailViewModel
import kotlinx.android.synthetic.main.activity_detail_layout.*

//盘点记录 ->  盘点详情
class InventoryDetailActivity:BaseActivity() {
    override fun getLayoutId() = R.layout.activity_detail_layout

    private val adapter = InventoryDetailAdapter()
    private val model by viewModels<InventoryOrderDetailViewModel>()

    override fun init() {
        setTitle("盘点详情")
        val id = intent.getIntExtra("id",-1)
        recyclerView.layoutManager = LinearLayoutManager(this)
        recyclerView.adapter = adapter

        model.reuqestSampleBox("$id") {
            tvOrderName.text = it.inventoryTable.name
            tvCount.text =
                "盘点进度${it.inventorySampleBoxList.filter { it.checkStatus == 1 }.size}/${it.inventorySampleBoxList.size}"
            adapter.setNewInstance(it.inventorySampleBoxList)
        }
    }

}
